<?php
$this->setLayout('template'.DS.'default.phtml');

$this->startBlock('topbar');
echo $this->navigation->toHtml();
$this->endBlock();

$this->startBlock();
?>
<form id="sort_form" method="post" action="<?echo $this->getUrl() ?>">
<ul id="sortable">
<?php foreach($this->menus as $menu):?>
<li class="ui-state-default" menu="<?php echo $menu->getId(); ?>"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span><?php echo $menu->getName(); ?></li>
<?php endforeach;?>
</ul>
<div id="hiddens"></div>
<div><button type="submit" class="button"><?php echo $this->__('share.button.save'); ?></button></div>
<input type="hidden" name="parent_id" value="<?php echo $this->menus[0]->getParentId() ?>"/>
</form>
<script language="javascript" type="text/javascript">
$(function() {
	$( "#sortable" ).sortable();
	$( "#sortable" ).disableSelection();
	$('#sort_form').submit(function(){
		var html = '';
		$('#sortable li').each(function(){
			html += '<input type="hidden" name="sorting[]" value="' + $(this).attr('menu') + '"/>';
		});
		$('#hiddens').html(html);
	});
});
</script>
<?php $this->endBlock(); ?>